<?php

namespace app\api\controller;

use app\api\BaseController;
use app\api\middleware\Auth;
use app\load\loadServices\OaServices;
use app\load\loadServices\TypeServices;
use think\Exception;

/**
 * 审批流程
 */
class Flow extends BaseController
{

    /**
     * 免登录方法
     * 控制器中间件 [登录 不需要鉴权]
     * @var array
     */
    protected $middleware = [
        Auth::class => ['except' => []]
    ];



    /**
     * 审批流程列表
     * @return void
     */
    public function list()
    {
        $input = input();
        try {
            $where[] = ['delete_time' , '=' , '0'];
            if (!empty($input['flow_cate'])) {
                $where[] = ['flow_cate','=',  $input['flow_cate']];
            }
            $product_list = OaServices::Flow()->list($where, 'id,name,check_type,type,flow_list,is_sign');
            $this->apiSuccess('请求成功', $product_list);
        } catch (Exception $e) {
            $this->apiError($e->getMessage());
        }

    }


    /**
     * 审批类型列表
     * @return void
     */
    public function list_type()
    {
        try {
            $product_list = TypeServices::FlowType()->list(
                ['status' => 1],
                'id,type,title,name,icon,create_time');
            $this->apiSuccess('请求成功', $product_list);
        } catch (Exception $e) {
            $this->apiError($e->getMessage());
        }

    }


}